﻿using System;
using System.Collections.Generic;
using KKSG;
using MiniJSON;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x02000D1A RID: 3354
	internal class X3DTouchMgr : XSingleton<X3DTouchMgr>
	{
		// Token: 0x0600BB11 RID: 47889 RVA: 0x002664A0 File Offset: 0x002646A0
		public void OnProcess3DTouch(string msg = "")
		{
			bool flag = Time.time - this._last_touch_time < 1f;
			if (!flag)
			{
				this._last_touch_time = Time.time;
				bool flag2 = XSingleton<XChatIFlyMgr>.singleton.IsRecording() || XSingleton<XChatApolloMgr>.singleton.IsInRecordingState;
				if (!flag2)
				{
					bool flag3 = !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Photo);
					if (!flag3)
					{
						XSingleton<XDebug>.singleton.AddLog("The dict: ", msg, null, null, null, null, XDebugColor.XDebug_None);
						bool flag4 = !string.IsNullOrEmpty(msg);
						if (flag4)
						{
							Dictionary<string, object> dictionary = Json.Deserialize(msg) as Dictionary<string, object>;
							bool flag5 = dictionary != null && dictionary.ContainsKey("data");
							if (flag5)
							{
								Dictionary<string, object> dictionary2 = dictionary["data"] as Dictionary<string, object>;
								bool flag6 = dictionary2 != null;
								if (flag6)
								{
									bool flag7 = dictionary2.ContainsKey("index_x") && dictionary2["index_x"] != null;
									if (flag7)
									{
										string s = dictionary2["index_x"].ToString();
										float.TryParse(s, out this._pointx);
									}
									bool flag8 = dictionary2.ContainsKey("index_y") && dictionary2["index_y"] != null;
									if (flag8)
									{
										string s2 = dictionary2["index_y"].ToString();
										float.TryParse(s2, out this._pointy);
									}
									float num = 2f;
									bool flag9 = Screen.height == 1080 && Screen.width == 1920;
									if (flag9)
									{
										num = 2.6f;
									}
									this._pointx *= num;
									this._pointy = (float)Screen.height - this._pointy * num;
								}
							}
						}
						XSingleton<XDebug>.singleton.AddLog("Process 3d touch", null, null, null, null, null, XDebugColor.XDebug_None);
						bool flag10 = XSingleton<XSceneMgr>.singleton.IsPVPScene() || XSingleton<XSceneMgr>.singleton.IsPVEScene();
						if (flag10)
						{
							bool flag11 = XSingleton<XScene>.singleton.GameCamera != null && XSingleton<XEntityMgr>.singleton.Player != null;
							if (flag11)
							{
								Vector2 vector = new Vector2(this._pointx, this._pointy);
								XSingleton<XDebug>.singleton.AddLog("Touch screen pos: ", vector.x.ToString(), ", y:", vector.y.ToString(), null, null, XDebugColor.XDebug_None);
								XSingleton<XDebug>.singleton.AddLog("Is touch on ui: ", XTouch.PointOnUI(vector).ToString(), null, null, null, null, XDebugColor.XDebug_None);
								bool flag12 = !XTouch.PointOnUI(vector);
								if (flag12)
								{
									bool flag13 = XSingleton<XVirtualTab>.singleton.Feeding && vector.x <= (float)(Screen.width / 2);
									if (!flag13)
									{
										bool flag14 = XSingleton<XScene>.singleton.GameCamera.BackToPlayer();
										bool flag15 = !flag14;
										if (flag15)
										{
											XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("ERR_CAMERA_ROT"), "fece00");
										}
									}
								}
							}
						}
						else
						{
							SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
							if (sceneType <= SceneType.SCENE_GUILD_HALL)
							{
								if (sceneType != SceneType.SCENE_HALL && sceneType != SceneType.SCENE_GUILD_HALL)
								{
									goto IL_348;
								}
							}
							else if (sceneType != SceneType.SCENE_FAMILYGARDEN && sceneType != SceneType.SCENE_LEISURE)
							{
								goto IL_348;
							}
							this.OnProcessScreenShot(msg);
							IL_348:;
						}
					}
				}
			}
		}

		// Token: 0x0600BB12 RID: 47890 RVA: 0x002667F8 File Offset: 0x002649F8
		private void OnProcessScreenShot(string msg)
		{
			bool flag = XSingleton<XVirtualTab>.singleton.Feeding && this._pointx <= (float)(Screen.width / 2);
			if (!flag)
			{
				bool flag2 = DlgBase<GuildTerritoryMainDlg, GuildTerritoryMainBehaviour>.singleton.IsLoaded() && DlgBase<GuildTerritoryMainDlg, GuildTerritoryMainBehaviour>.singleton.IsVisible();
				if (!flag2)
				{
					bool flag3 = DlgBase<SuperRiskDlg, SuperRiskDlgBehaviour>.singleton.IsLoaded() && DlgBase<SuperRiskDlg, SuperRiskDlgBehaviour>.singleton.IsVisible();
					if (!flag3)
					{
						bool flag4 = DlgBase<DungeonSelect, DungeonSelectBehaviour>.singleton.IsLoaded() && DlgBase<DungeonSelect, DungeonSelectBehaviour>.singleton.IsVisible();
						if (!flag4)
						{
							bool flag5 = DlgBase<XTeamView, TabDlgBehaviour>.singleton.IsLoaded() && DlgBase<XTeamView, TabDlgBehaviour>.singleton.IsVisible();
							if (!flag5)
							{
								bool flag6 = DlgBase<SevenLoginDlg, SevenLoginBehaviour>.singleton.IsLoaded() && DlgBase<SevenLoginDlg, SevenLoginBehaviour>.singleton.IsVisible();
								if (flag6)
								{
									DlgBase<SevenLoginDlg, SevenLoginBehaviour>.singleton.SetVisible(false, true);
								}
								bool flag7 = DlgBase<XOptionsView, XOptionsBehaviour>.singleton.IsLoaded() && DlgBase<XOptionsView, XOptionsBehaviour>.singleton.IsVisible();
								if (flag7)
								{
									DlgBase<XOptionsView, XOptionsBehaviour>.singleton.SetVisible(false, true);
								}
								bool flag8 = DlgBase<TitleDlg, TitleDlgBehaviour>.singleton.IsLoaded() && DlgBase<TitleDlg, TitleDlgBehaviour>.singleton.IsVisible();
								if (flag8)
								{
									DlgBase<TitleDlg, TitleDlgBehaviour>.singleton.SetVisibleWithAnimation(false, null);
								}
								bool flag9 = DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.IsLoaded() && DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.IsVisible();
								if (flag9)
								{
									DlgBase<CarnivalDlg, CarnivalBehavior>.singleton.SetVisible(false, true);
								}
								bool flag10 = DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsLoaded() && DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible() && DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.fakeShow;
								if (flag10)
								{
									DlgBase<ScreenShotShareView, ScreenShotShareBehaviour>.singleton.SetVisible(true, true);
									DlgBase<ScreenShotShareView, ScreenShotShareBehaviour>.singleton.ShowMainView();
								}
								else
								{
									bool flag11 = DlgBase<ScreenShotShareView, ScreenShotShareBehaviour>.singleton.IsInReadyScreenShowView();
									if (flag11)
									{
										DlgBase<ScreenShotShareView, ScreenShotShareBehaviour>.singleton.IOS3DTouchScreenShot();
									}
								}
							}
						}
					}
				}
			}
		}

		// Token: 0x0600BB13 RID: 47891 RVA: 0x000FEEFC File Offset: 0x000FD0FC
		private void OnCameraStraightForward()
		{
		}

		// Token: 0x04004B72 RID: 19314
		private float _last_touch_time = 0f;

		// Token: 0x04004B73 RID: 19315
		private float _pointx = 0f;

		// Token: 0x04004B74 RID: 19316
		private float _pointy = 0f;
	}
}
